package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.MyFabulous;
import cn.wolfcode.trip.base.mapper.MyFabulousMapper;
import cn.wolfcode.trip.base.query.MyFabulousQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IMyFabulousService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

@Service
public class MyFabulousServiceImpl implements IMyFabulousService {
    @Autowired
    private  MyFabulousMapper fabulousMapper;
   /* @Override
    public void save(MyFabulous fabulous) {
        //设置创建时间
        fabulous.setCreateTime(new Date());
        fabulousMapper.insert(fabulous);
    }*/

    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(fabulousMapper.query(qo));
    }


    /**
     * 查询收到私信消息赞的数量
     * @return
     */
    @GetMapping("/{id}")
    public int queryFabulousCount(QueryObject qo){
        fabulousMapper.queryFabulousCount(qo);
        return fabulousMapper.queryFabulousCount(qo);
    }

    @Override
    public void changeState(Long fabulouId) {
        fabulousMapper.changeState(fabulouId);
    }

    @Override
    public MyFabulous checkHasFabulous(MyFabulousQueryObject qo) {
        return fabulousMapper.checkHasFabulous(qo);
    }

    @Override
    public void save(MyFabulous mf) {
        fabulousMapper.deleteFabulous(mf);
        fabulousMapper.insert(mf);
    }

   /* public void delete(QueryObject qo) {
        fabulousMapper.deleteByThreeIdAndUserId(qo);
    }*/

   /* public Boolean checkHasFabulous(Long strategydetailId, Long travelId, Long dailyId, Long userId) {
        if (strategydetailId != null || travelId != null || dailyId != null) {
            Integer count = fabulousMapper.selectByThreeIdAndUserId(strategydetailId, travelId, dailyId, userId);
            if (count > 0) {
                return true;
            }
        }
        return false;
    }*/
}
